import http from '@/util/http'
export default {
  state: {
    login: false,
    info: {}
  },
  getters: {
    'GET_INFO': function ({info}) {
      return info
    }
  },
  mutations: {
    'UPDATE_INFO' (state, info) {
      Object.assign(state.info, info)
    },
    'CHANGE_LOGIN' ({login}, status) {
      login = status !== -1
    }
  },
  actions: {
    fetchInfo ({commit}) {
      http.get('info').then(function ({data}) {
        commit('CHANGE_LOGIN', data.status)
        commit('UPDATE_INFO', data.data)
      })
    },
    updateInfo ({commit}, postData) {
      http.post('info', postData).then(function ({data}) {

      })
    }
  }
}
